﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

namespace IdentityService
{
    public class UserDal : IUserDal
    {
        public User FindByUsername(string userName)
        {
            User user = new User();
            if (userName.Equals("li"))
            {
                user.SubjectId = "1";
                user.Username = "li";
                user.Password = "123456";
                user.Claims = new List<Claim>() {
                new Claim(ClaimTypes.Role,"Admin"),
                new Claim(ClaimTypes.Role,"User"),
                new Claim(ClaimTypes.Role,"Administrator")
                };
                return user;
            }
            else
            {
                return null;
            }
        }

        public bool ValidateCredentials(string userName, string userPwd)
        {
            if (userName.Equals("li") && userPwd.Equals("123456"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
